import { _decorator, Component,  Sprite, UITransform, view, Widget } from 'cc';
import { createUILabel, createUINode } from '../utils';
const { ccclass } = _decorator;

@ccclass('LoadingElement')
export class LoadingElement extends Component {
    init(preLoadingFrame) {
        const node = createUINode("背景图片")
        node.setParent(this.node)
        let designSize = view.getVisibleSize()
        const transform=node.getComponent(UITransform)
        transform.setContentSize(designSize.width,designSize.height)
        const sprite = node.addComponent(Sprite)
        sprite.sizeMode=Sprite.SizeMode.CUSTOM
        sprite.spriteFrame = preLoadingFrame
        this.createTipsLabel()
    }
    createTipsLabel() {
        const tips = createUINode("")
        tips.setParent(this.node)
        let text = `健康游戏忠告\n
        抵制不良游戏，拒绝盗版游戏。注意自我保护，谨防受骗上当。适度游戏益脑，沉迷游戏伤身。合理安排时间，享受健康生活`
        createUILabel({parentNode:tips,text,fontSize:22,lineHeight:22,color:"#fbfbfd"})
        const widget=tips.addComponent(Widget)
        widget.isAlignBottom=true
        widget.bottom=0
    }
}


